package test.serverframe.armc.server.manager.dao.mapper;

import org.apache.ibatis.jdbc.SQL;
import test.serverframe.armc.server.manager.domain.InterfaceInvokingRecord;

public class InterfaceInvokingRecordSqlProvider {

    public String insertSelective(InterfaceInvokingRecord record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("tb_ssgp_interface_invoking_record");
        
        if (record.getInterfaceInvokingRecordId() != null) {
            sql.VALUES("interface_invoking_record_id", "#{interfaceInvokingRecordId,jdbcType=VARCHAR}");
        }
        
        if (record.getInvokeTaskRecordId() != null) {
            sql.VALUES("invoke_task_record_id", "#{invokeTaskRecordId,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskRelateInterId() != null) {
            sql.VALUES("task_relate_inter_id", "#{taskRelateInterId,jdbcType=VARCHAR}");
        }
        
        if (record.getStartTime() != null) {
            sql.VALUES("start_time", "#{startTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEndTime() != null) {
            sql.VALUES("end_time", "#{endTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getStatus() != null) {
            sql.VALUES("status", "#{status,jdbcType=BIT}");
        }
        
        if (record.getReturnValue() != null) {
            sql.VALUES("return_value", "#{returnValue,jdbcType=LONGVARCHAR}");
        }
        
        if (record.getAssertValue() != null) {
            sql.VALUES("assert_value", "#{assertValue,jdbcType=LONGVARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(InterfaceInvokingRecord record) {
        SQL sql = new SQL();
        sql.UPDATE("tb_ssgp_interface_invoking_record");
        
        if (record.getInvokeTaskRecordId() != null) {
            sql.SET("invoke_task_record_id = #{invokeTaskRecordId,jdbcType=VARCHAR}");
        }
        
        if (record.getTaskRelateInterId() != null) {
            sql.SET("task_relate_inter_id = #{taskRelateInterId,jdbcType=VARCHAR}");
        }
        
        if (record.getStartTime() != null) {
            sql.SET("start_time = #{startTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEndTime() != null) {
            sql.SET("end_time = #{endTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("status = #{status,jdbcType=BIT}");
        }
        
        if (record.getReturnValue() != null) {
            sql.SET("return_value = #{returnValue,jdbcType=LONGVARCHAR}");
        }
        
        if (record.getAssertValue() != null) {
            sql.SET("assert_value = #{assertValue,jdbcType=LONGVARCHAR}");
        }
        
        sql.WHERE("interface_invoking_record_id = #{interfaceInvokingRecordId,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}